home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / misc / football / user / cup_viewhistory.rexx < prev    next >
OS/2 REXX Batch file  |  1999-02-03  |  4KB  |  180 lines

  1. /* ***********************************************************************
  2.  
  3.    VIEW TEAM SCHEDULE PROGRAM FOR FOOTBALL REXX SUITE
  4.   ----------------------------------------------------
  5.                    Copyright  Mark Naughton 1997
  6.  
  7.  
  8. Version    Date     History
  9. --------------------------------------------------------------------------
  10.  1.0       091297   First release.
  11.            151297   Tidied display.
  12.  
  13. **************************************************************************
  14.  
  15. Procedure
  16. ---------
  17.  
  18. 1. Check file exist.
  19. 2. Open '.cfh' file and read in winners, storing them and if the name
  20.    appears more than once, increment the number of wins for that team.
  21. 3. Read '.cfh' file in and store 'needed' lines.
  22. 4. Write teams for winners out to temp file and sort.
  23. 4. Check array and set marker if third place is found.
  24. 5. Display message. Display winners, runnersup, third place and fourth.
  25. 6. Read temp file and display winners with total wins. Exit.
  26.  
  27. ************************************************************************** */
  28. PARSE ARG league_stuff
  29.  
  30. version      = 1
  31. input_file   = '.cfh'
  32. first        = '*WINNER='
  33. second       = '*RUNNERUP='
  34. second       = '*THIRD='
  35. second       = '*FOURTH='
  36. cupnm        = '** History for '
  37. separator    = '*'
  38. teams.       = '???'
  39. wins.        = '???'
  40. lines.       = '???'
  41. counter      = 0
  42.  
  43.  
  44. league_file = "Data/" || league_stuff
  45.  
  46. if exists(league_file || input_file) = 0  then exit
  47.  
  48. if open(datafile,league_file || input_file,'r') then do
  49.    do while ~eof(datafile)
  50.       line = readln(datafile)
  51.       if pos(cupnm,line) > 0 then
  52.          cupname = delstr(line,1,15)
  53.       if pos(first,line) > 0 then do
  54.          name = delstr(line,1,8)
  55.          notin = 0
  56.          do i=1 to counter
  57.             if pos(name,teams.i) > 0 then do
  58.                wins.i = wins.i + 1
  59.                notin = 1
  60.             end
  61.          end
  62.          if notin = 0 then do
  63.             counter = counter + 1
  64.             teams.counter = name
  65.             wins.counter  = 1
  66.          end
  67.       end
  68.    end
  69.    close(datafile)
  70. end
  71. else do
  72.    say
  73.    say "ERROR :    (ViewHistory)"
  74.    say
  75.    say "Cannot open '"league_file||input_file"' for reading."
  76.    exit
  77. end
  78.  
  79. linect = 0
  80. if open(datafile,league_file || input_file,'r') then do
  81.    do while ~eof(datafile)
  82.       line = readln(datafile)
  83.       if pos('**',line) = 0 & length(line) > 2 & line ~= '' then do
  84.          linect = linect + 1
  85.          lines.linect = line
  86.       end
  87.    end
  88.    close(datafile)
  89. end
  90. else do
  91.    say
  92.    say "ERROR :    (ViewHistory)"
  93.    say
  94.    say "Cannot open '"league_file||input_file"' for reading."
  95.    exit
  96. end
  97.  
  98. if counter > 1 then do
  99.    if open(datafile,"RAM:Football.tempcup",'w') then do
  100.       do i=1 to counter
  101.          writeln(datafile,left(wins.i,4)"     "teams.i)
  102.       end
  103.       close(datafile)
  104.    end
  105.    else do
  106.       say
  107.       say "ERROR :    (ViewHistory)"
  108.       say
  109.       say "Cannot create temporary file."
  110.       exit
  111.    end
  112.    address command 'Exec/Sort4Chars '
  113. end
  114.  
  115. thirdp = 0
  116. do i=1 to linect
  117.    if pos(third,lines.i) > 0 then do
  118.       thirdp = 1
  119.       leave
  120.    end
  121. end
  122.  
  123. say
  124. say center("Display Cup History for "cupname,78)
  125. say "-------------------------------------------------------------------------------"
  126. say
  127.  
  128. do i=1 to linect
  129.    name = delstr(lines.i,1,8)
  130.    say "Winner       : "upper(name)
  131.    i = i + 1
  132.    name = delstr(lines.i,1,10)
  133.    say "Runner-Up    : "name
  134.    if thirdp = 1 then do
  135.       i = i + 1
  136.       name = delstr(lines.i,1,7)
  137.       say "Third Place  : "name
  138.       i = i + 1
  139.       name = delstr(lines.i,1,8)
  140.       say "Fourth Place : "name
  141.       say
  142.    end
  143.    else
  144.       say
  145. end
  146. say
  147. say
  148. say "Wins     Team"
  149. say "-------------------------------------------------------------------------------"
  150. say
  151. i = 0
  152. if counter = 1 then do
  153.    say left(wins.1,4)"     "upper(teams.1)
  154.    say
  155. end
  156. else do
  157.    if open(datafile,"RAM:Football.tempcup",'r') then do
  158.       do while ~eof(datafile)
  159.          line = readln(datafile)
  160.          if i = 0 then do
  161.             say upper(line)
  162.             i = 1
  163.          end
  164.          else
  165.             say line
  166.       end
  167.       close(datafile)
  168.    end
  169.    else do
  170.       say
  171.       say "ERROR :    (ViewHistory)"
  172.       say
  173.       say "Cannot read temporary file of teams to display the table of winners."
  174.       exit
  175.    end
  176.    address command 'delete >NIL: RAM:Football.tempcup'
  177. end
  178. say "-------------------------------------------------------------------------------"
  179.  
  180. exit